<!DOCTYPE HTML>
<html lang="zh-CN">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="nvm, B-612">
    <meta name="description" content="nvm install">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="referrer" content="no-referrer-when-downgrade">
    <!-- Global site tag (gtag.js) - Google Analytics -->


    <title>nvm | B-612</title>
    <link rel="icon" type="image/png" href="/favicon.png">
    


    <!-- bg-cover style     -->



<link rel="stylesheet" type="text/css" href="/libs/awesome/css/all.min.css">
<link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
<link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
<link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
<link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
<link rel="stylesheet" type="text/css" href="/css/matery.css">
<link rel="stylesheet" type="text/css" href="/css/my.css">
<link rel="stylesheet" type="text/css" href="/css/dark.css" media="none" onload="if(media!='all')media='all'">




    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
    <link rel="stylesheet" href="/css/post.css">




    
        <link rel="stylesheet" type="text/css" href="/css/reward.css">
    



    <script src="/libs/jquery/jquery-3.6.0.min.js"></script>

<meta name="generator" content="Hexo 6.3.0">
<style>.github-emoji { position: relative; display: inline-block; width: 1.2em; min-height: 1.2em; overflow: hidden; vertical-align: top; color: transparent; }  .github-emoji > span { position: relative; z-index: 10; }  .github-emoji img, .github-emoji .fancybox { margin: 0 !important; padding: 0 !important; border: none !important; outline: none !important; text-decoration: none !important; user-select: none !important; cursor: auto !important; }  .github-emoji img { height: 1.2em !important; width: 1.2em !important; position: absolute !important; left: 50% !important; top: 50% !important; transform: translate(-50%, -50%) !important; user-select: none !important; cursor: auto !important; } .github-emoji-fallback { color: inherit; } .github-emoji-fallback img { opacity: 0 !important; }</style>
<link rel="alternate" href="/atom.xml" title="B-612" type="application/atom+xml">
</head>


<body>
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                    <img src="/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">B-612</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>首页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>标签</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>分类</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>归档</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/tips" class="waves-effect waves-light">
      
      <i class="fa-solid fa-wand-magic-sparkles" style="zoom: 0.6;"></i>
      
      <span>附录</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>关于</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/friends" class="waves-effect waves-light">
      
      <i class="fas fa-address-book" style="zoom: 0.6;"></i>
      
      <span>友情链接</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
  <li>
    <a href="javascript:;" class="waves-effect waves-light" onclick="switchNightMode()" title="深色/浅色模式" >
      <i id="sum-moon-icon" class="fas fa-sun" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>


<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">B-612</div>
        <div class="logo-desc">
            
            Never really desperate, only the lost of the soul.
            
        </div>
    </div>

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			首页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			标签
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			分类
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			归档
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/tips" class="waves-effect waves-light">
			
			    <i class="fa-fw fa-solid fa-wand-magic-sparkles"></i>
			
			附录
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			关于
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/friends" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-address-book"></i>
			
			友情链接
		</a>
          
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://github.com/wangjueya/B612-Factory" class="waves-effect waves-light" target="_blank">
                <i class="fab fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>


        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://github.com/wangjueya/B612-Factory" class="github-corner tooltipped hide-on-med-and-down" target="_blank"
   data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewBox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
              fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
              fill="currentColor" class="octo-body"></path>
    </svg>
</a>
        
    </nav>

</header>

    



<div class="bg-cover pd-header post-cover" style="background-image: url('/medias/featureimages/13.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title">nvm</h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/tags/nvm-node/">
                                <span class="chip bg-color">nvm node</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                    <div class="post-cate">
                        <i class="fas fa-bookmark fa-fw icon-category"></i>
                        
                            <a href="/categories/07-Programming-Assistant/" class="post-category">
                                07-Programming-Assistant
                            </a>
                        
                    </div>
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2022-10-15
                </div>
                

                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-check fa-fw"></i>更新日期:&nbsp;&nbsp;
                    2024-11-09
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-file-word fa-fw"></i>文章字数:&nbsp;&nbsp;
                    2.7k
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-clock fa-fw"></i>阅读时长:&nbsp;&nbsp;
                    10 分
                </div>
                

                
                    <div id="busuanzi_container_page_pv" class="info-break-policy">
                        <i class="far fa-eye fa-fw"></i>阅读次数:&nbsp;&nbsp;
                        <span id="busuanzi_value_page_pv"></span>
                    </div>
				

                
                <div class="info-break-policy" style='margin-left: 3px'>
                    
                    <a target="_blank" rel="noopener" href="https://github.com/WANGJUEYA/magic-book/edit/master/07-Programming-Assistant/NVM.md">
                        <i class="far fa-regular fa-pen-to-square"></i>
                    </a>
                </div>
                
            </div>
        </div>
        <hr class="clearfix">

        
        <!-- 是否加载使用自带的 prismjs. -->
        <link rel="stylesheet" href="/libs/prism/prism.min.css">
        

        

        <div class="card-content article-card-content">
            <div id="articleContent">
                <h2 id="常用命令">常用命令</h2>
<pre class="line-numbers language-bash" data-language="bash"><code class="language-bash">nvm list available <span class="token comment"># 查看所有可用node版本</span>
nvm <span class="token function">install</span> <span class="token number">20.16</span>.0 <span class="token comment"># 安装node版本</span>
nvm use <span class="token number">20.16</span>.0 <span class="token comment"># 切换node版本</span>
<span class="token function">pnpm</span> config <span class="token builtin class-name">set</span> store-dir <span class="token operator">&lt;</span>new path<span class="token operator">&gt;</span> <span class="token comment"># pnpm设置缓存路径</span>
<span class="token function">pnpm</span> store path <span class="token comment"># pnpm查看缓存路径</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span></span></code></pre>
<p><a target="_blank" rel="noopener" href="https://gitcode.csdn.net/65e6e9c81a836825ed787ccc.html">nvm介绍原文地址</a></p>
<h2 id="前言">前言</h2>
<p>文章基于 <code>windows环境</code> 使用nvm安装多版本nodejs。mac可能不适用。<br>
最近公司有的项目比较老需要降低node版本才能运行，由于来回进行卸载不同版本的node比较麻烦；所以需要使用node工程多版本管理，后面自己就简单捯饬了一下nvm来管理node，顺便记录一下自己的使用过程以便于后续查找。</p>
<p><strong>注意：安装nvm时不能安装任何node版本（如存在请删除后再安装nvm），再检查环境变量，如果还有node.js相关也删掉，保证系统无任何node.js 残留。</strong><br>
<strong>卸载完之后cmd命令行输入 node -v 查看是否还能查到node信息，无的话表示删除干净。</strong></p>
<h2 id="一、卸载node">一、卸载node</h2>
<p>如果已经安装了node，那么在安装nvm之前，需要先卸载node，如果没有安装可以直接跳过这一步到下一步了。</p>
<p><strong>删除前可查当前使用的node版本，方便后续决定使用哪个版本的node。</strong></p>
<ul>
<li>控制面板 -&gt; 卸载程序 -&gt; 卸载nodejs</li>
<li>为了确保彻底删除node，看下node安装目录中还有没有node文件夹，有的话一起删除。</li>
<li>删除以下文件夹（如果存在的话）</li>
<li>C:\Program Files (x86)\Nodejs</li>
<li>C:\Program Files\Nodejs</li>
<li>C:\Users{User}\AppData\Roaming\npm</li>
<li>C:\Users{User}\AppData\Roaming\npm-cache</li>
<li>删除C:\Users\用户名 下的 <code>.npmrc</code>文件以及 <code>.yarnrc</code> 文件</li>
<li>环境变量中npm、node的所有相关统统删掉</li>
</ul>
<h2 id="二、nvm是什么？">二、nvm是什么？</h2>
<p>nvm（node.js version management），是一个nodejs的版本管理工具。nvm和n都是node.js版本管理工具，为了解决node.js <strong>各种版本存在不兼容现象</strong> 可以通过它可以安装和切换不同版本的node.js。【可同时在一个环境中安装多个node.js版本（和配套的npm）】</p>
<h2 id="三、nvm安装">三、nvm安装</h2>
<h3 id="1-官网下载-nvm-包">1. 官网下载 nvm 包</h3>
<p><a href="https://link.csdn.net/?target=https%3A%2F%2Fgithub.com%2Fcoreybutler%2Fnvm-windows%2Freleases%3Flogin%3Dfrom_csdn">https://github.com/coreybutler/nvm-windows/releases</a></p>
<p><img src="https://i-blog.csdnimg.cn/blog_migrate/fc49a4e08d6d2876812dbb0683db67eb.png" alt="在这里插入图片描述"></p>
<h3 id="2-安装-nvm-setup-exe">2. 安装 nvm-setup.exe</h3>
<p><img src="https://i-blog.csdnimg.cn/blog_migrate/c4070c75ab0ded466c41a43a2655313a.png" alt="在这里插入图片描述"></p>
<p><img src="https://i-blog.csdnimg.cn/blog_migrate/69616b85e591cdc159b3e3f9cadc72a8.png" alt="在这里插入图片描述"></p>
<p><strong>注意安装路径的文件夹名称不要出现中文，空格等，否则后期npm使用的时候会出现符号格式不正确问题。</strong></p>
<p>继续点击 Next 就行。</p>
<h3 id="3-配置路径和下载镜像">3. 配置路径和下载镜像</h3>
<p>安装完nvm后先不要着急安装node版本。</p>
<p><strong>找到nvm安装路径 =》找到 setting.txt 文件 =》新增两行信息，配置下载源</strong></p>
<pre class="line-numbers language-none"><code class="language-none">node_mirror: https://npmmirror.com/mirrors/node/
npm_mirror: https://npmmirror.com/mirrors/npm/<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span></span></code></pre>
<p><img src="https://i-blog.csdnimg.cn/blog_migrate/dd8bdda9b92ae12b4440896c0e95c21c.png" alt="在这里插入图片描述"></p>
<p>增加后如下，然后保存退出。</p>
<p><img src="https://i-blog.csdnimg.cn/blog_migrate/86759639c57a93f4d31023c2b0131c5f.png" alt="在这里插入图片描述"></p>
<blockquote>
<p><strong>第一行是 nvm安装路径</strong><br>
<strong>第二行是 nodejs路径</strong><br>
<strong>第三行是 node下载镜像</strong><br>
<strong>第四行是 npm下载镜像</strong></p>
</blockquote>
<p><strong>注意：因为淘宝的镜像域名更换，由于 <a target="_blank" rel="noopener" href="http://npm.taobao.org">npm.taobao.org</a> 域名HTTPS证书到期更换为 <a target="_blank" rel="noopener" href="http://npmmirror.com">npmmirror.com</a>，那么就会导致之前使用该镜像域名下载依赖的安装包会出现问题。</strong><br>
执行报错信息如下：</p>
<pre class="line-numbers language-none"><code class="language-none">&gt;nvm ls available

Could not retrieve https://npm.taobao.org/mirrors/node/index.json.


Get "https://npm.taobao.org/mirrors/node/index.json": x509: certificate has expired or is not yet valid:<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>
<h3 id="4-检查nvm是否安装完成">4. 检查nvm是否安装完成</h3>
<p>win + R，调用cmd，输入<code>nvm</code>，出现下面这一堆就表示安装成功了。</p>
<p>如果安装不成功，查看之前自己安装的 node.js 有没有彻底删除、安装nvm过程中有没有漏掉什么，可重新卸载再安装一次nvm包。</p>
<p><img src="https://i-blog.csdnimg.cn/blog_migrate/e5202b83df1e26d847dc5d209696f0c5.png" alt="在这里插入图片描述"></p>
<h2 id="四、使用nvm安装node版本">四、使用nvm安装node版本</h2>
<p>win + R，调用cmd</p>
<p>安装完成后开始插入nodejs首先使用 <code>nvm list available</code> 查询可插入版本号，LST表示可插入稳定版本。【如未指定版本，建议安装LTS下的版本】</p>
<p><img src="https://i-blog.csdnimg.cn/blog_migrate/175515ce295190fb6345817b591f6866.png" alt="在这里插入图片描述"></p>
<ol>
<li>安装指定node.js版本</li>
</ol>
<pre class="line-numbers language-none"><code class="language-none">nvm install 16.14.0<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>
<ol>
<li><code>nvm use</code> 切换node版本。(如果报错，用管理员身份打开重新 <code>nvm use</code> 你指定的版本）</li>
</ol>
<pre class="line-numbers language-none"><code class="language-none">nvm use 16.14.0<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>
<ol>
<li>安装完成后可以分别输入命令行 <code>node -v</code> 和 <code>npm -v</code>，检验node.js以及对应npm是否安装成功</li>
</ol>
<p><img src="https://i-blog.csdnimg.cn/blog_migrate/bfba1a58e0119542b8bd7faa8a50283c.png" alt="在这里插入图片描述"></p>
<ol>
<li><code>nvm list</code> 查看当前已安装的node.js版本，带*号的是正在使用的</li>
</ol>
<pre class="line-numbers language-none"><code class="language-none">nvm list
或者
nvm ls<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span></span></code></pre>
<p><img src="https://i-blog.csdnimg.cn/blog_migrate/06221e0afb17eea501246f6270c53c37.png" alt="在这里插入图片描述"></p>
<ol>
<li>删除某node.js版本</li>
</ol>
<pre class="line-numbers language-none"><code class="language-none">nvm uninstall node版本号  //例如：nvm uninstall 16.14.0）即可删除对应版本<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>
<ol>
<li>比如我现在安装的是 v16.14.0 版本。</li>
</ol>
<p><img src="https://i-blog.csdnimg.cn/blog_migrate/e38c77af77e5b4d976ea51442243a9f6.png" alt="在这里插入图片描述"></p>
<p>v16.14.0 文件内部是</p>
<p><img src="https://i-blog.csdnimg.cn/blog_migrate/cfc4abf66666dabeee515548b2099528.png" alt="在这里插入图片描述"></p>
<p>node_modules内部是这样的</p>
<p><img src="https://i-blog.csdnimg.cn/blog_migrate/bbd6cfe0a8ed17ab44965612a8b1de32.png" alt="在这里插入图片描述"></p>
<h2 id="五、修改npm默认镜像源为淘宝镜像">五、修改npm默认镜像源为淘宝镜像</h2>
<p>修改npm镜像源为淘宝镜像，加快npm包的下载速度，减少发生连接错误和超时的概率。</p>
<pre class="line-numbers language-none"><code class="language-none">npm config set registry https://registry.npmmirror.com<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>
<p>检查是否设置淘宝镜像成功（会返回这个地址表示成功：<a target="_blank" rel="noopener" href="https://registry.npmmirror.com">https://registry.npmmirror.com</a>）</p>
<pre class="line-numbers language-none"><code class="language-none">npm config get registry<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>
<p>关于使用 淘宝镜像 <code>https://registry.npm.taobao.org</code> 报错的问题</p>
<p><img src="https://i-blog.csdnimg.cn/blog_migrate/f6b06a9329cb422864b05d32809908a2.png" alt="在这里插入图片描述"></p>
<p>是因为从 2024 年1 月 22 日，淘宝原镜像域名（<a target="_blank" rel="noopener" href="http://registry.npm.taobao.org">registry.npm.taobao.org</a>）的 HTTPS 证书正式到期，这就导致旧的 npm 淘宝镜像在使用时出错了，所以遇到上述问题，或者还在使用旧的 npm 淘宝镜像，直接将 npm 源切换到新的源即可，文章链接：<a href="https://link.csdn.net/?target=https%3A%2F%2Fzhuanlan.zhihu.com%2Fp%2F679613901%3Flogin%3Dfrom_csdn">技术资讯：npm 淘宝镜像正式到期，赶紧更新！</a></p>
<pre class="line-numbers language-none"><code class="language-none">// 1. 清空缓存
npm cache clean --force
// 2. 切换新源
npm config set registry https://registry.npmmirror.com<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span></span></code></pre>
<h2 id="六、使用-nrm-来管理-npm-源">六、使用 nrm 来管理 npm 源</h2>
<p>这部分想管理npm源就下载一下，不下载只要上一步完成切换淘宝源镜像也可以，不会影响下面的其他操作，看个人意愿了。<br>
我们可以使用 nrm 来管理 npm 源，特别是当需要在不同的网络环境之间切换时，它可以提供更好的包管理体验。</p>
<blockquote>
<p>nrm（npm registry manager）是一个用于管理和切换 npm 源的命令行工具。它允许您在不同的 npm 源之间进行切换，以加快包的下载速度，或者解决特定源无法访问的问题。nrm 提供了一组命令，可以列出可用的 npm 源、添加新源、测试源的响应速度，并切换当前使用的源。</p>
</blockquote>
<p>首先，通过以下命令来安装 nrm：</p>
<pre class="line-numbers language-none"><code class="language-none">npm install -g nrm<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>
<p>以下是一些常见的 nrm 命令：</p>
<p>1）列出可用的源：当前配置的所有可用 npm 源以及它们的名称和 URL。</p>
<pre class="line-numbers language-none"><code class="language-none">nrm ls<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>
<p>例如：</p>
<p><img src="https://i-blog.csdnimg.cn/blog_migrate/8b014536df0c615d206d1e0d112f9268.png" alt="在这里插入图片描述"></p>
<p>2）切换源：将当前的 npm 源切换为指定的源。可以使用源的名称或 URL 作为 参数。</p>
<pre class="line-numbers language-none"><code class="language-none">nrm use &lt;registry&gt;<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>
<p>3）添加源：添加一个新的 npm 源并指定其名称和 URL。</p>
<pre class="line-numbers language-none"><code class="language-none">nrm add &lt;registry&gt; &lt;url&gt;<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>
<p>4）删除源：删除指定的 npm 源，需要提供源的名称或 URL 作为 参数。</p>
<pre class="line-numbers language-none"><code class="language-none">nrm del &lt;registry&gt;<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>
<p>5）测试源的速度：测试指定源的响应速度，并显示测试结果。</p>
<pre class="line-numbers language-none"><code class="language-none">nrm test &lt;registry&gt;<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>
<p>6）显示当前使用的源：当前正在使用的 npm 源的名称和 URL。</p>
<pre class="line-numbers language-none"><code class="language-none">nrm current<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>
<h2 id="七、-环境变量配置">七、 环境变量配置</h2>
<h3 id="1-设置系统变量和用户变量的作用是什么呢？">1. 设置系统变量和用户变量的作用是什么呢？</h3>
<p>答：为了命令行安装包时，将包安装到自己设置的目录下。</p>
<h3 id="2-配置步骤">2. 配置步骤</h3>
<h4 id="1）新增俩文件夹">1）新增俩文件夹</h4>
<ol>
<li>首先创建<code>"node_global"</code> 和 <code>“node_cache”</code>两个文件夹进行全局安装的时候安装对应的库到这两个文件。<br>
在nvm的 <code>nodejs</code> 安装路径 <code>C:\Program Files\nodejs</code> 新建两个文件夹命名为 <code>"node_global"</code> 和 <code>“node_cache”</code>。</li>
</ol>
<p><img src="https://i-blog.csdnimg.cn/blog_migrate/321c254cf21e0378bce6394f171dca20.png" alt="在这里插入图片描述"></p>
<ol>
<li>打开cmd命令行工具，输入以下两句操作（两个路径就是新建上面两个文件夹的路径，主要目的是方便后面window机器使用方便）</li>
</ol>
<pre class="line-numbers language-none"><code class="language-none">npm config set prefix "C:\Program Files\nodejs\node_global"
npm config set cache "C:\Program Files\nodejs\node_cache"<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span></span></code></pre>
<p>执行成功就无任何响应，没有异常的话，就在去到 环境变量设置处。</p>
<h4 id="2）设置环境变量">2）设置环境变量</h4>
<p>我的电脑右键 =》属性 =》高级系统设置 =》系统属性（高级）=》 环境变量，进入环境变量对话框。</p>
<p>如果环境变量未正确配置，输入<code>node -v</code> 会报错，系统将无法正确识别"node"命令。</p>
<p>需要我们设置的地方有两个：</p>
<blockquote>
<p><strong>1. 系统环境变量新增 NODE_PATH 变量</strong><br>
<strong>2. 用户变量修改 path 变量</strong></p>
</blockquote>
<ol>
<li>在【系统变量】新建环境变量 <code>NODE_PATH</code> 值为 <code>C:\Program Files\nodejs\node_global\node_modules</code>，<br>
其中<code>C:\Program Files\nodejs\node_global\node_modules</code> 就是上面创建的全局模块安装路径文件夹。</li>
</ol>
<p><img src="https://i-blog.csdnimg.cn/blog_migrate/f67863657503b8540173a8139917ec25.png" alt="在这里插入图片描述"></p>
<ol>
<li>修改 【用户变量】中的 <code>path</code> 变量<br>
这里我其实没有修改或者增加什么变量，是安装时候默认添加的。<br>
<img src="https://i-blog.csdnimg.cn/blog_migrate/d82b69602aed9879257bc48e961c433e.png" alt="在这里插入图片描述"><br>
<img src="https://i-blog.csdnimg.cn/blog_migrate/85f124092dff15bdd4363019d4895a34.png" alt="在这里插入图片描述"></li>
<li>另外下载完 nvm 之后，系统环境变量和用户环境变量会默认帮我们配置好 <code>NVM_HOME</code> 和 <code>NVM_SYMLINK</code></li>
</ol>
<p><img src="https://i-blog.csdnimg.cn/blog_migrate/0d7dd9e26f23b220e97c238ee6b282eb.png" alt="在这里插入图片描述"></p>
<ol>
<li>点击确定后配置完成。</li>
</ol>
<h2 id="八、测试安装全局模块">八、测试安装全局模块</h2>
<p>测试是否环境变量是否配置成功，在cmd窗口中输入以下指定全局安装express模块，安装成功的话表示环境变量配置成功。</p>
<pre class="line-numbers language-none"><code class="language-none">npm install -g express<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>
<p><img src="https://i-blog.csdnimg.cn/blog_migrate/87bd94492cc23a7e362501960acdbecf.png" alt="在这里插入图片描述"></p>
<h2 id="九、卸载nvm">九、卸载nvm</h2>
<ol>
<li>先删除你当初所安装的nvm、nodejs的文件夹即可。<br>
<img src="https://i-blog.csdnimg.cn/blog_migrate/526bca0a8cf493a749578e66aa2fe04d.png" alt="在这里插入图片描述"></li>
</ol>
<p><img src="https://i-blog.csdnimg.cn/blog_migrate/12063fecfb0d3fc27926fa475e2ddfd8.png" alt="在这里插入图片描述"></p>
<ol>
<li>桌面右键 此电脑 – 点击属性 – 找到高级系统设置 – 环境变量。</li>
<li>删除用户变量 和 系统变量中名为 <code>NVM_HOME</code> 和 <code>NVM_SYMLINK</code> 两个变量。其他的不要改。</li>
</ol>
<p><img src="https://i-blog.csdnimg.cn/blog_migrate/a4c9c0f9e7f8c64da6d3232ab43a3677.png" alt="在这里插入图片描述"></p>
<ol>
<li>删除用户变量和系统变量中path中的 %NVM_HOME%，%NVM_SYMLINK% 两个属性，还有c盘中的node_cache，node_global，其他的不要改。<br>
<img src="https://i-blog.csdnimg.cn/blog_migrate/914badf5a4e7922bd3a250c400a6351c.png" alt="在这里插入图片描述"></li>
</ol>
<h2 id="十、遇到的问题">十、遇到的问题</h2>
<blockquote>
<p><strong>1. 在安装 nvm 之前没有卸载掉 node，导致 nvm 安装完之后，node和npm都不可用。所以我们在拿到一个新电脑时候最好是先下载nvm，再安装node版本。</strong><br>
<strong>2. 在第一次使用nvm安装node后，记得使用 nvm use 切换下node版本，以及用 nvm on 打开nodejs版本控制，不然这时候node和npm也都不可用。</strong><br>
3. <strong>使用 淘宝镜像 <a target="_blank" rel="noopener" href="https://registry.npm.taobao.org">https://registry.npm.taobao.org</a> 报错的问题，因为淘宝原镜像域名（<a target="_blank" rel="noopener" href="http://registry.npm.taobao.org">registry.npm.taobao.org</a>）的 HTTPS 证书正式到期； npm <a target="_blank" rel="noopener" href="http://xn--registry-g00mv2qcxdcoz52h32gv3vdi2btj1d52ue.npmmirror.com">淘宝镜像已经切换到了registry.npmmirror.com</a>，使用命令行重新切换就可以了 npm config set registry <a target="_blank" rel="noopener" href="https://registry.npmmirror.com">https://registry.npmmirror.com</a></strong>，文章链接：<a href="https://link.csdn.net/?target=https%3A%2F%2Fzhuanlan.zhihu.com%2Fp%2F679613901%3Flogin%3Dfrom_csdn">技术资讯：npm 淘宝镜像正式到期，赶紧更新！</a></p>
</blockquote>
<p>可参考：<br>
<a href="https://link.csdn.net/?target=https%3A%2F%2Fblog.csdn.net%2Fpdd11997110103%2Farticle%2Fdetails%2F115981856%3Flogin%3Dfrom_csdn">使用nvm管理node.js版本以及更换npm淘宝镜像源</a><br>
<a href="https://link.csdn.net/?target=http%3A%2F%2F681314.com%2FA%2FpaXERvv5T8%3Flogin%3Dfrom_csdn">win10环境使用nvm安装多版本nodejs并配置环境变量</a><br>
<a href="https://link.csdn.net/?target=https%3A%2F%2Fblog.csdn.net%2FHuangsTing%2Farticle%2Fdetails%2F113857145%3Flogin%3Dfrom_csdn">window下安装并使用nvm（含卸载node、卸载nvm、全局安装npm）</a><br>
<a href="https://link.csdn.net/?target=https%3A%2F%2Fblog.csdn.net%2FyeahPeng11%2Farticle%2Fdetails%2F120606669%3Flogin%3Dfrom_csdn">安装并搭建Vue项目【安装node，设置npm镜像】</a></p>

                
            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        文章作者:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="/about" rel="external nofollow noreferrer">艾茜茜</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="http://wangjueya.github.io/nvm/">http://wangjueya.github.io/nvm/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="/about" target="_blank">艾茜茜</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/tags/nvm-node/">
                                    <span class="chip bg-color">nvm node</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">
<div id="article-share">

    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
                <div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-medium waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fas fa-times"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/medias/reward/alipay.png" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>

            
        </div>
    </div>

    

    

    

    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/json/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/8.jpg" class="responsive-img" alt="Json">
                        
                        <span class="card-title">Json</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            Json
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2022-10-15
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/04-Programming-Languages/" class="post-category">
                                    04-Programming-Languages
                                </a>
                            
                            <a href="/categories/04-Programming-Languages/Assistant-File-Types/" class="post-category">
                                    Assistant-File-Types
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/tomcat/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/12.jpg" class="responsive-img" alt="Tomcat">
                        
                        <span class="card-title">Tomcat</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            Tomcat
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2022-10-15
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/07-Programming-Assistant/" class="post-category">
                                    07-Programming-Assistant
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/Tomcat/">
                        <span class="chip bg-color">Tomcat</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>



<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/libs/codeBlock/codeBlockFuction.js"></script>


  <!-- 是否加载使用自带的 prismjs. -->
  <script type="text/javascript" src="/libs/prism/prism.min.js"></script>


<!-- 代码语言 -->

<script type="text/javascript" src="/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->

<script type="text/javascript" src="/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/libs/codeBlock/codeShrink.js"></script>



    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget card" style="background-color: white;">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h2, h3, h4'
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>




    <footer class="page-footer bg-color">
    
        <link rel="stylesheet" href="/libs/aplayer/APlayer.min.css">
<style>
    .aplayer .aplayer-lrc p {
        
        display: none;
        
        font-size: 12px;
        font-weight: 700;
        line-height: 16px !important;
    }

    .aplayer .aplayer-lrc p.aplayer-lrc-current {
        
        display: none;
        
        font-size: 15px;
        color: #42b983;
    }

    
    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body {
        left: -66px !important;
    }

    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body:hover {
        left: 0px !important;
    }

    
</style>
<div class="">
    
    <div class="row">
        <meting-js class="col l8 offset-l2 m10 offset-m1 s12"
                   server="netease"
                   type="playlist"
                   id="503838841"
                   fixed='true'
                   autoplay='false'
                   theme='#42b983'
                   loop='all'
                   order='random'
                   preload='auto'
                   volume='0.7'
                   list-folded='true'
        >
        </meting-js>
    </div>
</div>

<script src="/libs/aplayer/APlayer.min.js"></script>
<script src="/libs/aplayer/Meting.min.js"></script>

    

    <div class="container row center-align"
         style="margin-bottom: 0px !important;">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            
                <span id="year">2019-2025</span>
            
            <a href="/about" target="_blank">艾茜茜</a>
            |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
            |&nbsp;Theme&nbsp;<a href="https://github.com/WANGJUEYA/hexo-theme-christmas-tree.git" target="_blank">christmas-tree</a>
            <br>
            
                &nbsp;<i class="fas fa-chart-area"></i>&nbsp;站点总字数:&nbsp;<span
                        class="white-color">67.8k</span>
            
            
            
                
            
            
                <span id="busuanzi_container_site_pv">
                &nbsp;|&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;
                    <span id="busuanzi_value_site_pv" class="white-color"></span>
            </span>
            
            
                <span id="busuanzi_container_site_uv">
                &nbsp;|&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;
                    <span id="busuanzi_value_site_uv" class="white-color"></span>
            </span>
            
            <br>

            <!-- 运行天数提醒. -->
            
            <br>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://github.com/wangjueya" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fab fa-github"></i>
    </a>



    <a href="mailto:573711282@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>







    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=573711282" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 573711282" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>







    <a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fas fa-rss"></i>
    </a>

</div>
    </div>
</footer>

<div class="progress-bar"></div>


    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script type="text/javascript">
$(function () {
    var searchFunc = function (path, search_id, content_id) {
        'use strict';
        $.ajax({
            url: path,
            dataType: "xml",
            success: function (xmlResponse) {
                // get the contents from search data
                var datas = $("entry", xmlResponse).map(function () {
                    return {
                        title: $("title", this).text(),
                        content: $("content", this).text(),
                        url: $("url", this).text()
                    };
                }).get();
                var $input = document.getElementById(search_id);
                var $resultContent = document.getElementById(content_id);
                $input.addEventListener('input', function () {
                    var str = '<ul class=\"search-result-list\">';
                    var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                    $resultContent.innerHTML = "";
                    if (this.value.trim().length <= 0) {
                        return;
                    }
                    // perform local searching
                    datas.forEach(function (data) {
                        var isMatch = true;
                        var data_title = data.title.trim().toLowerCase();
                        var data_content = data.content.trim().replace(/<[^>]+>/g, "").toLowerCase();
                        var data_url = data.url;
                        data_url = data_url.indexOf('/') === 0 ? data.url : '/' + data_url;
                        var index_title = -1;
                        var index_content = -1;
                        var first_occur = -1;
                        // only match artiles with not empty titles and contents
                        if (data_title !== '' && data_content !== '') {
                            keywords.forEach(function (keyword, i) {
                                index_title = data_title.indexOf(keyword);
                                index_content = data_content.indexOf(keyword);
                                if (index_title < 0 && index_content < 0) {
                                    isMatch = false;
                                } else {
                                    if (index_content < 0) {
                                        index_content = 0;
                                    }
                                    if (i === 0) {
                                        first_occur = index_content;
                                    }
                                }
                            });
                        }
                        // show search results
                        if (isMatch) {
                            str += "<li><a href='" + data_url + "' class='search-result-title'>" + data_title + "</a>";
                            var content = data.content.trim().replace(/<[^>]+>/g, "");
                            if (first_occur >= 0) {
                                // cut out 100 characters
                                var start = first_occur - 20;
                                var end = first_occur + 80;
                                if (start < 0) {
                                    start = 0;
                                }
                                if (start === 0) {
                                    end = 100;
                                }
                                if (end > content.length) {
                                    end = content.length;
                                }
                                var match_content = content.substr(start, end);
                                // highlight all keywords
                                keywords.forEach(function (keyword) {
                                    var regS = new RegExp(keyword, "gi");
                                    match_content = match_content.replace(regS, "<em class=\"search-keyword\">" + keyword + "</em>");
                                });

                                str += "<p class=\"search-result\">" + match_content + "...</p>"
                            }
                            str += "</li>";
                        }
                    });
                    str += "</ul>";
                    $resultContent.innerHTML = str;
                });
            }
        });
    };

    searchFunc('/search.xml', 'searchInput', 'searchResult');
});
</script>

    <!-- 白天和黑夜主题 -->
<div class="stars-con">
    <div id="stars"></div>
    <div id="stars2"></div>
    <div id="stars3"></div>  
</div>

<script>
    function switchNightMode() {
        $('<div class="Cuteen_DarkSky"><div class="Cuteen_DarkPlanet"></div></div>').appendTo($('body')),
        setTimeout(function () {
            $('body').hasClass('DarkMode') 
            ? ($('body').removeClass('DarkMode'), localStorage.setItem('isDark', '0'), $('#sum-moon-icon').removeClass("fa-sun").addClass('fa-moon')) 
            : ($('body').addClass('DarkMode'), localStorage.setItem('isDark', '1'), $('#sum-moon-icon').addClass("fa-sun").removeClass('fa-moon')),
            
            setTimeout(function () {
            $('.Cuteen_DarkSky').fadeOut(1e3, function () {
                $(this).remove()
            })
            }, 2e3)
        })
    }
</script>

    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/libs/materialize/materialize.min.js"></script>
    <script src="/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/libs/aos/aos.js"></script>
    <script src="/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/js/matery.js"></script>

    
        <!-- <script src='https://unpkg.com/mermaid@latest/dist/mermaid.min.js'></script> -->
        <script src='/libs/mermaid/mermaid.min.js'></script>
        <script>
          if (window.mermaid) {
            mermaid.initialize({theme: 'forest'});
          }
        </script>
    

    

    <!-- 雪花特效 -->
    

    <!-- 鼠标星星特效 -->
    

     
        <script src="https://ssl.captcha.qq.com/TCaptcha.js"></script>
        <script src="/libs/others/TencentCaptcha.js"></script>
        <button id="TencentCaptcha" data-appid="xxxxxxxxxx" data-cbfn="callback" type="button" hidden></button>
    

    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/libs/others/busuanzi.pure.mini.js"></script>
    

    

    

    <!--腾讯兔小巢-->
    
    

    

    

    
    <script src="/libs/instantpage/instantpage.js" type="module"></script>
    

</body>

</html>
